<!--
  @Descripttion:：简历查看/预览
  @Author：yejianbo
  @Date：2022年05月22日 03:06:59
-->
<template>
  <section class="resume-review">
    <!-- 个人基本信息 -->
    <section class="block">
      <div class="head-icon">
        <img
          v-if="userInfo.studentPictureUrl"
          class="touxiang"
          :src="userInfo.studentPictureUrl"
          alt="用户头像"
        >
        <img
          v-else
          class="touxiang"
          src="@/assets/images/touxiang1.png"
          alt="用户头像"
        >
      </div>
      <div class="user-info">
        <div class="row1">
          {{ userInfo.studentName }}
          <span>学生</span>
        </div>
        <div class="row2">
          {{ userInfo.sex }}<span class="line" />{{ userInfo.age
          }}<span class="line" />{{ userInfo.liveCity
          }}<span class="line" />{{ userInfo.clan }}<span class="line" />{{ Number(userInfo.identify) === 0 ? '在校' : '应届' }}
          <br>
          <!-- <div class="row3">
            <span class="label">手机号码</span>
            <el-tooltip
              class="item"
              effect="dark"
              :content="userInfo.phoneNumber"
              placement="top-start"
            >
              <span class="label">{{ userInfo.phoneNumber }}</span>
            </el-tooltip>
          </div>
          <div class="row4">
            <span class="label">邮箱地址</span>
            <el-tooltip
              class="item"
              effect="dark"
              :content="userInfo.email"
              placement="top-start"
            >
              <span class="label">{{ userInfo.email }}</span>
            </el-tooltip>
          </div> -->
        </div>
      </div>
    </section>
    <!-- 求职意向 -->
    <section class="block pt30">
      <p class="title">求职意向</p>
      <div
        v-for="(item, index) in internshipDesire"
        :key="index"
        class="job-wish-item"
      >
        <div class="row1">
          {{ item.jobName }}<span class="line" />{{ item.lowestSalary }}-{{
            item.highestSalary
          }}/月<span class="line" />{{ item.targetCity }}
        </div>
        <div
          v-for="(it, i) in item.expectedIndustry"
          :key="i"
          class="job-type"
        >
          <span v-if="it">{{ it }}</span>
        </div>
      </div>
    </section>
    <!-- 工作/实习经历 -->
    <section class="block pt30">
      <p class="title">工作/实习经历</p>
      <div
        v-for="(item, index) in workExperience"
        :key="index"
        class="word-record-item"
      >
        <div class="row1">{{ item.entryTime }}~{{ item.resignationTime }}</div>
        <div class="row2">{{ item.companyName }}</div>
        <div class="row3">{{ item.jobName }}</div>
        <div class="row4">
          <span class="label">职位类型</span><span class="value">{{ ["实习", "全职"][item.jobType] }}</span>
          <span class="label">所属行业</span><span class="value">{{ item.industry }}</span>
        </div>
        <div
          v-if="item.jobDescription"
          class="row5"
          v-html="item.jobDescription.replace(/\n/gm, '<br>')"
        />
      </div>
    </section>
    <!-- 项目经历 -->
    <section class="block pt30">
      <p class="title">项目经历</p>
      <div
        v-for="(item, index) in projectExperience"
        :key="index"
        class="word-record-item"
      >
        <div class="row1">{{ item.beginTime }}~{{ item.endTime }}</div>
        <div class="row2">{{ item.projectName }}</div>
        <div
          v-if="item.projectDescription"
          class="row5"
          v-html="item.projectDescription.replace(/\n/gm, '<br>')"
        />
      </div>
    </section>
    <!-- 教育经历 -->
    <section class="block pt30">
      <p class="title">教育经历</p>
      <div
        v-for="(item, index) in educationalExperience"
        :key="index"
        class="word-record-item"
      >
        <div class="row2">{{ item.schoolName }}</div>
        <div class="row1">
          {{ item.intakeTime + "~" + item.graduateTime }}
        </div>
        <div class="row1">
          {{ item.educationalBackground }}<span class="line" />
          {{ item.major }}<span class="line" /><span> {{ ["无", "有"][item.diploma] }}学位证书</span>
        </div>
      </div>
    </section>
    <!-- 已修课程 -->
    <section class="block pt30">
      <p class="title">已修课程</p>
      <div
        v-for="(item, index) in courses"
        :key="index"
        class="word-record-item"
      >
        <div class="row1">{{ item.time }}</div>
        <div class="row2">{{ item.coursesName }}</div>
      </div>
    </section>
    <!-- 语言能力 -->
    <section class="block pt30">
      <p class="title">语言能力</p>
      <div
        v-for="(item, index) in languageAbility"
        :key="index"
        class="word-record-item"
      >
        <div class="row2">
          {{ item.languageName }}<span>{{ item.level }}</span>
        </div>
      </div>
    </section>
    <!-- 专业技能 -->
    <section class="block pt30">
      <p class="title">专业技能</p>
      <div
        v-for="(item, index) in specialtyAbility"
        :key="index"
        class="word-record-item"
      >
        <div class="row2">
          {{ item.specialtyName }}<span>{{ item.level }}</span>
        </div>
      </div>
    </section>
    <!-- 证书 -->
    <section class="block pt30">
      <p class="title">证书</p>
      <div
        v-for="(item, index) in certificates"
        :key="index"
        class="word-record-item"
      >
        <div class="row2">
          {{ item.certificatesName }}<span>{{ item.time }}</span>
        </div>
      </div>
    </section>
    <!-- 社会实践/活动经历 -->
    <section class="block pt30">
      <p class="title">社会实践/活动经历</p>
      <div
        v-for="(item, index) in practiceExperience"
        :key="index"
        class="word-record-item"
      >
        <div class="row1">{{ item.beginTime }}~{{ item.endTime }}</div>
        <div class="row2">{{ item.practiceName }}</div>
        <div
          v-if="item.practiceDescription"
          class="row5"
          v-html="item.practiceDescription.replace(/\n/gm, '<br>')"
        />
      </div>
    </section>
  </section>
</template>
<script>
import { getAge } from '@/utils'
export default {
  // 组件名称
  name: 'ResumeReview',
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data() {
    return {
      userInfo: {
        studentName: '',
        studentPictureUrl: '',
        sex: '',
        age: '',
        liveCity: '',
        clan: '',
        email: '',
        phoneNumber: ''
      },
      internshipDesire: [], // 实习意向
      educationalExperience: [], // 教育经历列表
      workExperience: [], // 工作、实习经历列表
      projectExperience: [], // 项目经历列表
      languageAbility: [], // 语言能力列表
      specialtyAbility: [], // 专业技能列表
      certificates: [], // 证书列表
      courses: [], // 已修课程列表
      practiceExperience: [] // 实践经验
    }
  },
  // 组件方法
  methods: {
    fetchJSON(str, key) {
      if (!str) return []
      const arr = JSON.parse(str)
      if (arr.length <= 0) return []
      this[key] = arr
    },
    open(resumeData) {
      if (resumeData) {
        // fix bug，解决简历数据覆盖
        Object.assign(this, this.$options.data())
        for (const key in this.userInfo) {
          if (Object.hasOwnProperty.call(resumeData, key)) {
            this.userInfo[key] = resumeData[key]
          }
        }
        this.userInfo.age = getAge(resumeData.birthday) + '岁'
        this.fetchJSON(resumeData.internshipDesire, 'internshipDesire') // 求职意向
        this.fetchJSON(
          resumeData.educationalExperience,
          'educationalExperience'
        ) // 教育经历
        this.fetchJSON(resumeData.workExperience, 'workExperience') // 实习经历
        this.fetchJSON(resumeData.projectExperience, 'projectExperience') // 项目经理
        this.fetchJSON(resumeData.languageAbility, 'languageAbility') // 语言能力
        this.fetchJSON(resumeData.specialtyAbility, 'specialtyAbility') // 专业技能
        this.fetchJSON(resumeData.certificates, 'certificates') // 证书
        this.fetchJSON(resumeData.courses, 'courses') // 课程
        this.fetchJSON(resumeData.practiceExperience, 'practiceExperience') // 社会实践活动
      }
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.resume-review {
  position: relative;
  width: 100%;
  background: #f5f8fa;
  .edit-btn {
    position: absolute;
    top: 30px;
    right: 30px;
  }
  .block {
    position: relative;
    background: #fff;
    margin-bottom: 20px;
  }
  .pt30 {
    padding: 30px 40px;
  }
  .head-icon {
    position: relative;
    background: url("../../../../assets/images/blue_bg.png") no-repeat center
      center / cover;
    width: 100%;
    height: 225px;
    > img {
      display: block;
      width: 128px;
      height: 128px;
      position: absolute;
      left: 50%;
      bottom: 0;
      transform: translate3d(-50%, 50%, 0);
      overflow: hidden;
    }
  }
  .user-info {
    position: relative;
    padding: 73px 0 56px;
    text-align: center;
    .row1 {
      position: relative;
      line-height: 50px;
      font-weight: 600;
      color: #37383d;
      font-size: 36px;
      text-align: center;
      margin-bottom: 12px;
      span {
        display: inline-block;
        border-radius: 6px;
        border: 1px solid #2f8efe;
        font-size: 20px;
        font-weight: 400;
        color: #2f8efe;
        line-height: 36px;
        padding: 0 12px;
        margin-left: 15px;
        vertical-align: middle;
        // &.line{
        //   position: relative;
        //   display: inline-block;
        //   width: 1px;
        //   height: 14px;
        //   background: #9597a0;
        //   margin: 0 18px;
        // }
      }
    }
    .row2 {
      position: relative;
      display: inline-block;
      text-align: center;
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 28px;
      .line {
        position: relative;
        display: inline-block;
        width: 1px;
        height: 14px;
        background: #9597a0;
        margin: 0 18px;
      }
    }
    .row3 {
      position: absolute;
      display: inline-block;
      left: 0;
      top: 49px;
      width: 100%;
      text-align: left;
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 28px;
      margin-top: 21px;
      .label {
        position: relative;
        display: inline-block;
        width: 60%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .label:first-child {
        width: 40%;
      }
    }
    .row4 {
      position: absolute;
      display: inline-block;
      left: 0;
      top: 92px;
      width: 100%;
      text-align: left;
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 28px;
      margin-top: 21px;
      .label {
        position: relative;
        display: inline-block;
        width: 60%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .label:first-child {
        width: 40%;
      }
    }
  }
  .title {
    font-size: 28px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #37383d;
    line-height: 40px;
    margin: 0 0 30px;
    padding: 0;
  }
  .job-wish-item {
    .row1 {
      font-size: 24px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 33px;
      margin-bottom: 20px;
      .line {
        position: relative;
        display: inline-block;
        width: 1px;
        height: 17px;
        background: #9597a0;
        margin: 0 25px;
      }
    }
    .job-type {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 28px;
    }
  }
  .word-record-item {
    padding-bottom: 27px;
    border-bottom: 1px solid #d4d6da;
    margin-bottom: 30px;
    &:last-child {
      border-bottom: 1px solid #fff;
    }
    .row1 {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 28px;
      margin-bottom: 15px;
    }
    .row2 {
      font-size: 24px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #37383d;
      line-height: 33px;
      margin-bottom: 15px;
      span {
        font-size: 24px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #9597a0;
        line-height: 33px;
        margin-left: 218px;
      }
    }
    .row3 {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 28px;
      margin-bottom: 15px;
      .line {
        position: relative;
        display: inline-block;
        width: 1px;
        height: 17px;
        background: #9597a0;
        margin: 0 25px;
      }
    }
    .row4 {
      margin-bottom: 20px;
      .label {
        font-size: 20px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #9597a0;
        line-height: 28px;
        margin-right: 17px;
      }
      .value {
        font-size: 20px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #030303;
        line-height: 28px;
        margin-right: 130px;
      }
    }
    .row5 {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #3c3c3c;
      line-height: 37px;
    }
  }
}
</style>
